package loginTest.dao.impl;

import jdbc.MyJDBCUtil;
import loginTest.User;
import loginTest.dao.UserDao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UserDaoimpl implements UserDao {
    @Override
    public User getUser() throws SQLException {
        Connection con= MyJDBCUtil.getConnection();
        Statement st=con.createStatement();
        String sql="select name,password from user";
        ResultSet rst=st.executeQuery(sql);
        User user = null;
        while (rst.next()){
            user=new User();
            user.setName(rst.getString(1));
            user.setPassword(rst.getString(2));
        }
        return user;
    }
}
